/*
 * Copyright (C) 2009,2010,2011  Paulo Cesar Pereira de Andrade.
 *
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * Authors:
 *	Paulo Cesar Pereira de Andrade
 */

#ifndef _enote_h
#define _enote_h

#include "etypes.h"

/*
 * Types
 */
typedef struct enote	enote_t;
typedef struct eline	eline_t;

struct enote {
    eint8_t	*code;
    evector_t	*name;		/* function name */
    eline_t	*lines;
    eint32_t	 count;
    eint32_t	 length;	/* length of code */
};

struct eline {
    evector_t	*name;		/* file name */
    eint32_t	*linenos;
    eint32_t	*offsets;
    eint32_t	 count;
};

/*
 * Prototypes
 */
extern void
enew_note(eobject_t *pointer, eint8_t *base, evector_t *name);

extern void
eset_note(enote_t *note, eint32_t length);

/* resize memory to match exact amount required */
extern void
efinish_note(enote_t *note);

extern void
eannotate(enote_t *note, evector_t *name, eint32_t lineno, eint32_t offset);

extern ebool_t
eget_note(eobject_t code, evector_t **func, evector_t **file, eint32_t *line);

extern void
init_note(void);

/* resize notes vector possibly releasing some memory  */
extern void
finish_note(void);

/*
 * Externs
 */
extern enote_t	*note_vector;
extern eint32_t	 note_count;

#endif /* _enote_h */
